package com.interview.javabasic.Collection;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class SafeHashMapDemo {
    //让hashmap线程安全
    public static void main(String[] args) {
        Map hashMap = new HashMap();
        Map safehashMap = Collections.synchronizedMap(hashMap);
        safehashMap.put("aa","1");
        safehashMap.put("bb","2");
        System.out.println(safehashMap.get("bb"));
    }
}
